package com.earthea.scaffold.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.earthea.common.constant.BaseConstants;
import com.earthea.scaffold.common.entity.BaseInsertableEntity;
import com.earthea.scaffold.common.enums.CommonStatusEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 文件对象 t_sys_file
 *
 * @author zhysunny
 * @date 2025-09-22
 */
@Getter
@Setter
@ToString
@TableName("t_sys_file")
public class SysFile extends BaseInsertableEntity {

    /**
     * 头像id
     */
    @TableId(type = IdType.AUTO)
    private Long fileId;

    /**
     * 文件类型
     */
    @ExcelProperty(value = "文件类型")
    @ColumnWidth(12)
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String fileType;

    /**
     * 文件MD5
     */
    @ExcelProperty(value = "文件MD5")
    @ColumnWidth(12)
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String fileMd5;

    /**
     * 文件大小
     */
    @ExcelProperty(value = "文件大小")
    @ColumnWidth(12)
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Long fileSize;

    /**
     * 压缩后的Base64数据
     */
    @ExcelProperty(value = "压缩后的Base64数据")
    @ColumnWidth(36)
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String fileData;

    /**
     * 帐号状态（0正常 1停用）
     */
    @ExcelProperty(value = "状态")
    @ColumnWidth(6)
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_EMPTY)
    private CommonStatusEnum status;

    public String getFileName() {
        return fileMd5 + BaseConstants.DOT + fileType;
    }

    public String getFilePath() {
        return "/resource/" + getFileName();
    }

}
